<?php
$title = '一个 PHP 日志归档算法 - aaaaa - wang lei\'s homepage';
include_once('../header.php');
include_once('../daohang_c.php');
echo '<p><strong>'.$title.'</strong></p>';?>
是在类中的一个函数,代码如下:<xmp>	/**
	 * 日志归档缓存
	 */
	private function mc_record() {
		$query = $this->db->query("select date from " . DB_PREFIX . "blog WHERE hide='n' and type='blog' ORDER BY date DESC");
		$record = 'xxxx_x';
		$p = 0;
		$lognum = 1;
		$dang_cache = array();
		while ($show_record = $this->db->fetch_array($query)) {
			$f_record = gmdate('Y_n', $show_record['date']);
			if ($record != $f_record) {
				$h = $p-1;
				if ($h != -1) {
					$dang_cache[$h]['lognum'] = $lognum;
				}
				$dang_cache[$p] = array('record' => gmdate("Y年n月", $show_record['date']),
					'url' => '?record=' . gmdate("Ym", $show_record['date'])
					);
				$p++;
				$lognum = 1;
			}else {
				$lognum++;
				continue;
			}
			$record = $f_record;
		}
		$j = $p-1;
		if ($j >= 0) {
			$dang_cache[$j]['lognum'] = $lognum;
		}

		$cacheData = serialize($dang_cache);
		$this->cacheWrite($cacheData, 'record');
	}</xmp>
<?php include_once('../footer.php');
